'''
Created on 11 Oct 2009

@author: joao
'''
import time
import math

class SolutionAndTime(object):
	def __init__(self, solution=0, time=0):
		self._solution = solution
		self._time = time
	
	def solution(self):
		return self._solution
	
	def time(self):
		return self._time
	
	def __str__(self):
		return "Solution: %d | Time:%0.3fs" % \
				( self.solution(), self.time())


class Problem(object):
	
	def __init__(self, problemNum, etcDir = "../etc/"):
		self._problemNum = problemNum
		self.etcDir = etcDir
	
	def problemNum(self):
		return self._problemNum
	
	def getEtcDir(self):
		return self.etcDir
	
	def setEtcDir(self, etcDir):
		self.etcDir = etcDir
	
	def solve(self):
		raise NotImplementedError
	
	def solveAndTime(self):
		startTime = time.time()
		solution = self.solve()
		endTime = time.time()
		execTime = endTime - startTime
		return SolutionAndTime(solution=solution, time=execTime)

class ProblemExample(Problem):
	def __init__(self):
		Problem.__init__(self, 0)
	
	def solve(self):
		for _i in range(1000000):
			solution = math.sqrt(4387498372847)
		return solution
